# 例子 7: 支持in操作的自定义类
class CustomSet:
    def __init__(self, elements):
        self.elements = set(elements)

    def __contains__(self, item):
        return item in self.elements


cs = CustomSet([1, 2, 3])
print(2 in cs)  # 输出: True
print(4 in cs)  # 输出: False
